@extends('admin_system/public/layout')
@section('content')
    <div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title">添加礼物</h3>
        </div>
        <div class="panel-body">
            <form action="/admin_system/live/gift/edit/{{$gift->id}}/save" method="post" enctype="multipart/form-data">
                {{csrf_field()}}
                <div class="form-group">
                    <label for="inputID" class="control-label">礼物名称:</label>
                    <div class="">
                        <input type="text" name="name" id="name" class="form-control" value="{{$gift->name}}" title=""
                               required="required">

                    </div>
                </div>

                <div class="form-group">
                    <label for="inputID" class="control-label">礼物图片:</label>
                    <hr>
                    <img src="/{{$gift->img_url}}" class="img-responsive" id="pre_img" width="144" alt="Image">
                    <hr>
                    <div class="">
                        <input type="file" name="img_url" id="img_url" class="form-control" value="" title="">
                    </div>
                </div>


                <div class="form-group">
                    <label for="inputID" class="control-label">价格:</label>
                    <div class="">
                        <input type="text" name="price" id="price" class="form-control" value="{{$gift->price}}"
                               title=""
                               required="required">
                    </div>
                </div>

                <input type="hidden" name="id" value="{{$gift->id}}">
                <div class="">
                    <button type="submit" class="btn btn-info" style="width: 100%">添加</button>
                </div>
            </form>
        </div>

        <script>
            var img_url = document.getElementById('img_url');
            var pre_img = document.getElementById('pre_img');
            img_url.onchange = function (e) {
                let file = e.target.files[0];
                var src = URL.createObjectURL(file);
                pre_img.setAttribute('src', src);
                console.log(src);
            }
        </script>
    </div>
@endsection